package com.example.english.activity;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.example.english.App;
import com.example.english.R;

public class ModifyPasswordActivity extends AppCompatActivity {

    private EditText et_pwd1 ,et_pwd2;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.acitivty_modify);
        et_pwd1 = findViewById(R.id.et_pwd1);
        et_pwd2 = findViewById(R.id.et_pwd2);
    }

    public void onModify(View view){
        if(TextUtils.isEmpty(et_pwd1.getText().toString()) || TextUtils.isEmpty(et_pwd2.getText().toString())){
            Toast.makeText(this ,"请输入密码",Toast.LENGTH_SHORT).show();
            return;
        }
        if(!et_pwd1.getText().toString().equals(et_pwd2.getText().toString())){
            Toast.makeText(this ,"两次密码输入不一致",Toast.LENGTH_SHORT).show();
            return;
        }
        App.dbsqLite.update(App.account ,et_pwd1.getText().toString());
        Toast.makeText(this ,"修改成功，下次登录将启用新密码",Toast.LENGTH_SHORT).show();
        finish();
    }

    public void onFinish(View view){
        finish();
    }

}
